//
//  DonateViewController.m
//  ZhiHuDaily
//
//  Created by albert on 2017/2/25.
//  Copyright © 2017年 albert. All rights reserved.
//

#import "DonateViewController.h"
#import "NavBarView.h"
#import "JKProgressHUD.h"
#import "JKImageBrowserView.h"

@interface DonateViewController ()
/** navBarView */
@property (nonatomic, weak) NavBarView *navBarView;
@property (weak, nonatomic) IBOutlet UILabel *QQLabel;
@property (weak, nonatomic) IBOutlet UILabel *eMailLabel;
@end

@implementation DonateViewController

- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    
    [self updateSkin];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 导航条View
    NavBarView *navBarView = [NavBarView barViewWithTitle:@"联系与捐赠" showBackTitle:NO];
    navBarView.backgroundColor = JKMainColor;
    [navBarView deleteBackButtonTitle];
    __weak typeof(self) weakSelf = self;
    [navBarView setBackBtnClickBlock:^(UIButton *button) {
        [weakSelf.navigationController popViewControllerAnimated:YES];
    }];
    [self.view addSubview:navBarView];
    self.navBarView = navBarView;
    
    UILongPressGestureRecognizer *qqPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(qqCopy:)];
    [self.QQLabel addGestureRecognizer:qqPress];
    
    UILongPressGestureRecognizer *eMailPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(eMailCopy:)];
    [self.eMailLabel addGestureRecognizer:eMailPress];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateSkin) name:JKSkinModelDidChangedNotification object:nil];
    
    [self updateSkin];
}

- (void)qqCopy:(UILongPressGestureRecognizer *)longPress{
    if (longPress.state == UIGestureRecognizerStateBegan) {
        UIPasteboard *pb = [UIPasteboard generalPasteboard];
        pb.string = @"790950645";
        [JKProgressHUD showSuccessWithStatus:@"复制成功！"];
    }
}

- (void)eMailCopy:(UILongPressGestureRecognizer *)longPress{
    if (longPress.state == UIGestureRecognizerStateBegan) {
        UIPasteboard *pb = [UIPasteboard generalPasteboard];
        pb.string = @"790950645@qq.com";
        [JKProgressHUD showSuccessWithStatus:@"复制成功！"];
    }
}

- (IBAction)wxDonate:(id)sender {
    [JKImageBrowserView showWithImage:[UIImage imageNamed:@"wx.jpg"]];
}

- (IBAction)zfbDonate:(id)sender {
    [JKImageBrowserView showWithImage:[UIImage imageNamed:@"zfb.jpg"]];
}

- (void)updateSkin{
    NSString *currentSkinModel = [[NSUserDefaults standardUserDefaults] objectForKey:JKCurrentSkinModelKey];
    
    if ([currentSkinModel isEqualToString:JKNightSkinModelValue]) { // 夜间模式
        self.view.backgroundColor = JKNightSkinColor;
        [self.navBarView changeToNightSkin];
        
    }else{ // 日间模式
        self.view.backgroundColor = JKGlobalBgColor;
        [self.navBarView changeToDaySkin];
    }
}

- (void)dealloc{
    [[NSNotificationCenter defaultCenter] removeObserver:self];;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
